package com.supostacks.application.application.impl;

import com.alibaba.fastjson.JSONObject;
import com.supostacks.application.application.IFeedbackApplication;
import com.supostacks.domain.repository.IFeedbackRepository;
import com.supostacks.domain.vo.BaseVo;
import com.supostacks.domain.vo.FeedbackVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Service
public class FeedbackApplicationImpl implements IFeedbackApplication {
    @Resource
    private IFeedbackRepository feedbackRepository;

    @Override
    public String insert(JSONObject data) {
        FeedbackVo feedbackVo = JSONObject.toJavaObject(data, FeedbackVo.class);
        return feedbackRepository.insert(feedbackVo);
    }

    @Override
    public void deleteById(String id) {
        feedbackRepository.deleteById(id);
    }

    @Override
    public String updateById(JSONObject data) {
        FeedbackVo feedbackVo = JSONObject.toJavaObject(data, FeedbackVo.class);
        return feedbackRepository.updateById(feedbackVo);
    }

    @Override
    public FeedbackVo selectById(String id) {
        return feedbackRepository.selectById(id);
    }

    @Override
    public List<BaseVo> selectList(JSONObject param) {
        List<FeedbackVo> feedbackVos = feedbackRepository.selectList(param);
        return new ArrayList<>(feedbackVos);
    }

    @Override
    public JSONObject selectByPage(JSONObject options, int pageNo, int pageSize) {
        return null;
    }

    @Override
    public List<BaseVo> search(JSONObject option) {
        return Collections.emptyList();
    }

}
